package com.kk.emp.controller;

import com.kk.emp.common.Const;
import com.kk.emp.entity.Emp;
import com.kk.emp.service.EmpService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/*
 *@author KK on 2022.10.08 0:03
 */
@Controller
@RequestMapping("/login")
public class LoginController{
    @Resource
    private EmpService empServices;

    /**
     * 登录
     * @param ename
     * @param pwd
     * @param session
     * @return
     */
    @RequestMapping
    public String login(String ename, String pwd, HttpSession session){
        Emp emp = empServices.doLogin(ename, pwd);
        if (emp != null) {
            session.setAttribute(Const.IS_LOGIN, emp);
            return "redirect:/emp/getEmpByPage";
        }
        return "redirect:/login.jsp";
    }


}
